<h1>Admin Home Page</h1>
<div id="logout">
	<?php echo anchor('admin/logout', 'Logout');?>
</div>
<h2>Add/Delete a User</h2>
<div id="add_student">
	<h3>Student</h3>
	<?php
		$hidden = array(
			'role' => 3
		);
		echo form_open('admin/add_user', '', $hidden);
	?>
	<table>
		<tr>
			<td><?php echo form_label('Student Number: ', 'std_stdno');?></td>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'name' => 'std_stdno',
						'value' => set_value('std_stdno')
					);
					echo form_input($data);
				?>
			</td>
			<td>
				<?php echo form_error('std_stdno'); ?>
			</td>
		</tr>
		<tr>
			<td><?php echo form_label('First Name: ', 'std_fname');?></td>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'name' => 'std_fname',
						'value' => set_value('std_fname')
					);
					echo form_input($data);
				?>
			</td>
			<td>
				<?php echo form_error('std_fname'); ?>
			</td>
		</tr>
		<tr>
			<td><?php echo form_label('Middle Initial: ', 'std_mname');?></td>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'name' => 'std_mname',
						'value' => set_value('std_mname')
					);
					echo form_input($data);
				?>
			</td>
			<td>
				<?php echo form_error('std_mname'); ?>
			</td>
		</tr>
		<tr>
			<td><?php echo form_label('Last Name: ', 'std_lname');?></td>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'name' => 'std_lname',
						'value' => set_value('std_lname')
					);
					echo form_input($data);
				?>
			</td>
			<td>
				<?php echo form_error('std_lname'); ?>
			</td>
		</tr>
		<!-- Added the field email address -->
		<tr>
			<td><?php echo form_label('Email Address: ', 'std_email');?></td>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'name' => 'std_email',
						'value' => set_value('std_email')
					);
					echo form_input($data);
				?>
			</td>
			<td>
				<?php echo form_error('std_email'); ?>
			</td>
		</tr>
		<tr>
			<td><?php echo form_label('Username: ', 'std_username');?></td>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'name' => 'std_username',
						'value' => set_value('std_username')
					);
					echo form_input($data);
				?>
			</td>
			<td>
				<?php echo form_error('std_username'); ?>
			</td>
		</tr>
		<tr>
			<td><?php echo form_label('Password: ', 'std_password');?></td>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'name' => 'std_password',
					);
					echo form_password($data);
				?>
			</td>
			<td>
				<?php echo form_error('std_password'); ?>
			</td>
		</tr>
		<tr>
			<td><?php echo form_label('Confirm Password: ', 'std_conf_password');?></td>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'name' => 'std_conf_password',
					);
					echo form_password($data);
				?>
			</td>
			<td>
				<?php echo form_error('std_conf_password'); ?>
			</td>
		</tr>
		<tr>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'value' => 'Create User',
					); 
					echo form_submit($data);
				?>
			</td>
		</tr>
	</table>
	<?php echo form_close(); ?>
	<table>
		<?php foreach ($std_list as $std) { ?>
			<tr>
				<td>
					<?php echo $std['username']; ?>
				</td>
				<td>
					<?php echo anchor('admin/delete_user/'.$std['username'].'/3', 'Delete'); ?>
				</td>
			</tr>
		<?php } ?>
	</table>
</div>

<div id="add_encoder">
	<h3>Encoder</h3>
	<?php
		$hidden = array(
			'role' => 2
		);
		echo form_open('admin/add_user', '', $hidden);
	?>
	<table>
		<tr>
			<td><?php echo form_label('Username: ', 'enc_username');?></td>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'name' => 'enc_username',
						'value' => set_value('enc_username')
					);
					echo form_input($data);
				?>
			</td>
			<td>
				<?php echo form_error('enc_username'); ?>
			</td>
		</tr>
		<tr>
			<td><?php echo form_label('Password: ', 'enc_password');?></td>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'name' => 'enc_password',
						'value' => set_value('enc_password')
					);
					echo form_password($data);
				?>
			</td>
			<td>
				<?php echo form_error('enc_password'); ?>
			</td>
			
		</tr>
		<tr>
			<td><?php echo form_label('Confirm Password: ', 'enc_conf_password');?></td>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'name' => 'enc_conf_password',
						'value' => set_value('enc_conf_password')
					);
					echo form_password($data);
				?>
			</td>
		</tr>
		<tr>
			<td><?php echo form_label('Name: ', 'enc_name');?></td>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'name' => 'enc_name',
						'value' => set_value('enc_name')
					);
					echo form_input($data);
				?>
			</td>
			<td>
				<?php echo form_error('enc_name'); ?>
			</td>
		</tr>
		<tr>
			<td><?php echo form_label('Role: ', 'enc_role');?></td>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'name' => 'enc_role',
						'value' => set_value('enc_role')
					);
					echo form_input($data);
				?>
			</td>
			<td>
				<?php echo form_error('enc_role'); ?>
			</td>
		</tr>
		<tr>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'value' => 'Create Encoder',
					); 
					echo form_submit($data);
				?>
			</td>
		</tr>
	</table>
	<?php echo form_close(); ?>
	<table>
		<?php foreach ($enc_list as $enc) { ?>
			<tr>
				<td>
					<?php echo $enc['username']; ?>
				</td>
				<td>
					<?php echo anchor('admin/delete_user/'.$enc['username'].'/2', 'Delete'); ?>
				</td>
			</tr>
		<?php } ?>
	</table>
</div>

<div id="add_instructor">
	<h3>Instructor</h3>
	<?php
		$hidden = array(
			'role' => 4
		);
		echo form_open('admin/add_user', '', $hidden);
	?>
	<table>
		<tr>
			<td><?php echo form_label('Employee ID: ', 'ins_emp_id');?></td>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'name' => 'ins_emp_id',
						'value' => set_value('ins_emp_id')
					);
					echo form_input($data);
				?>
			</td>
			<td>
				<?php echo form_error('ins_emp_id'); ?>
			</td>
		</tr>
		<tr>
			<td><?php echo form_label('Name: ', 'ins_name');?></td>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'name' => 'ins_name',
						'value' => set_value('ins_name')
					);
					echo form_input($data);
				?>
			</td>
			<td>
				<?php echo form_error('ins_name'); ?>
			</td>
		</tr>
		<tr>
			<td><?php echo form_label('Username: ', 'ins_username');?></td>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'name' => 'ins_username',
						'value' => set_value('ins_username')
					);
					echo form_input($data);
				?>
			</td>
			<td>
				<?php echo form_error('ins_username'); ?>
			</td>
		</tr>
		<tr>
			<td><?php echo form_label('Password: ', 'ins_password');?></td>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'name' => 'ins_password',
						'value' => set_value('ins_password')
					);
					echo form_password($data);
				?>
			</td>
			<td>
				<?php echo form_error('ins_name'); ?>
			</td>
		</tr>
		<tr>
			<td><?php echo form_label('Confirm Password: ', 'ins_conf_password');?></td>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'name' => 'ins_conf_password',
						'value' => set_value('ins_conf_password')
					);
					echo form_password($data);
				?>
			</td>
		</tr>
		<tr>
			<td>
				<?php
					$data = array(
						// You can add a class here later for styling.
						'value' => 'Create Instructor',
					); 
					echo form_submit($data);
				?>
			</td>
		</tr>
	</table>
	<?php echo form_close(); ?>
	<table>
		<?php foreach ($ins_list as $ins) { ?>
			<tr>
				<td>
					<?php echo $ins['username']; ?>
				</td>
				<td>
					<?php echo anchor('admin/delete_user/'.$ins['username'].'/4', 'Delete'); ?>
				</td>
			</tr>
		<?php } ?>
	</table>
</div>

<h2>Approve/Disapprove Users</h2>
<div id="approve_users">
	<h3>Students</h3>
	<table>
	<?php
		foreach ($unapproved_std as $std) {
			echo "<tr>";
			echo "<td>".$std['username']."</td>";
			echo "<td>".anchor('admin/approve/'.$std['username'].'/3', 'Approve')."</td>";
			echo "<td>".anchor('admin/disapprove/'.$std['username'].'/3', 'Disapprove')."</td>";
			echo "</tr>";
		}
	?>
	</table>
</div>

<h2>Activate/Deactivate Users</h2>
<div id="activate_users">
	<h3>Students</h3>
	<table>
	<?php
		foreach ($active_status_std as $std) {
			echo "<tr>";
			echo "<td>".$std['username']."</td>";
			if ($std['activated'])
				echo "<td>".anchor('admin/deactivate/'.$std['username'].'/3', 'Deactivate')."</td>";
			else
				echo "<td>".anchor('admin/activate/'.$std['username'].'/3', 'Activate')."</td>";
			echo "</tr>";
		}
	?>
	</table>
	<h3>Encoders</h3>
	<table>
	<?php
		foreach ($active_status_enc as $enc) {
			echo "<tr>";
			echo "<td>".$enc['username']."</td>";
			if ($enc['activated'])
				echo "<td>".anchor('admin/deactivate/'.$enc['username'].'/2', 'Deactivate')."</td>";
			else
				echo "<td>".anchor('admin/activate/'.$enc['username'].'/2', 'Activate')."</td>";
			echo "</tr>";
		}
	?>
	</table>
	<h3>Instructors</h3>
	<table>
	<?php
		foreach ($active_status_ins as $ins) {
			echo "<tr>";
			echo "<td>".$ins['username']."</td>";
			if ($ins['activated'])
				echo "<td>".anchor('admin/deactivate/'.$ins['username'].'/4', 'Deactivate')."</td>";
			else
				echo "<td>".anchor('admin/activate/'.$ins['username'].'/4', 'Activate')."</td>";
			echo "</tr>";
		}
	?>
	</table>
</div>

<h2>Logs</h2>
<div id="logs">
	<table>
		<thead>
			<th>Name</th>
			<th>Action</th>
			<th>Time</th>
		</thead>
		<tbody>
			<?php
				foreach ($log_list as $l) {
					echo "<tr>";
					echo "<td>".$l['name']."</td>";
					echo "<td>".$l['action']."</td>";
					echo "<td>".$l['time']."</td>";
					echo "</tr>";
				}
			?>
		</tbody>
	</table>
</div>

<h2>Send Message</h2>
<div id="send_message">
	<table>
		<thead>
			<th>Sender</th>
			<th>Message</th>
		</thead>
		<tbody>
			<?php
				foreach ($inbox as $i) {
					echo "<tr>";
					echo "<td>".$i['sender']."</td>";
					echo "<td>".$i['message']."</td>";
					echo "</tr>";
				}
			?>
		</tbody>
	</table>
	<?php echo form_open('admin/sendMessage');?>
		To:<br />
		<input type="text" name="to" /><br />
		Message: <br />
		<textarea name="message"></textarea><br />
		<input type="submit" value="Send Message" />
	<?php echo form_close(); ?>
</div>